<?php
use Application\Model\vn3dUtil;
?>
<style>
#vn3d-table-product img {
	height: 23px !important;
	width: 61px !important;
}
</style>
<script type="text/javascript">

var productID="";
function closeFancybox(){
	$.fancybox.close();
}
function loadAddtocart(){
	$.ajax({
        url: "/store/add-to-cart/"+productID,
        type: "POST",
        dataType:"html",
//	        data: {
//	               order_by:orderby,
//	               order:order,
//	        	   rowperpage:rowperpage,
//	        	   typeView:typeView
//	        	}, //The data your sending to page
        success: function(html){
        $("#inline-addtocart").html(html);
        $("#inline").click();

        setTimeout(function(){closeFancybox(); },3000);


        },
        error:function(){
            console.log("AJAX request was a failure");
        }
      });
}
$(document).ready(function(){

	$(".btn-link-addtocart").click(function(){
		productID=$(this).attr("product");
		loadAddtocart();
	});




      $(document).on("click","#vn3d-continuous",function(){
    	  closeFancybox();
          });


});

</script>

<div id="vn3d-table-product">
	<table class="table">
		<thead>
			<tr>
				<th></th>
				<th>Product</th>
				<th>Product code</th>
				<th>Price</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
      <?php foreach ($paginator as $key => $product) {?>

        <tr>
				<td>
          <?php echo vn3dUtil::getBannerProductLink($product);?>
          </td>
				<td><a
					href="/store/product/<?php echo $product->id;?>/<?php echo vn3dUtil::convertUrlSeo($product->name);?>">
				<?php echo $product->name;?>
				</a></td>
				<td><small>CODE:<?php echo $product->code;?></small></td>
				<td>$<?php echo $product->price;?>.00</td>
				<td><button type="button" class="btn btn-link btn-link-addtocart"
						product="<?php echo $product->id;?>"><span class="text-danger">ADD TO CART></span></button></td>
			</tr>
        <?php
    }
    ?>
      </tbody>
	</table>
</div>
<center>
<?php

echo $this->paginationControl($paginator, 'Sliding', '/layout/ProductPaginator.phtml', array(
    'action' => $action,
    'route' => $route,
    'order_by' => $order_by,
    'order' => $order,
    'groupProductID' => $groupProductID,
    'urlSeo' => vn3dUtil::convertUrlSeo($groupProduct->name)
));
?>
</center>
<a id="inline" href="#inline-addtocart" style="display: none;">add to cart</a>
<div style="display: none;" id="inline-addtocart">add to cart</div>